//-------------------------------------------------------------------------
/**
   File:   root_key_handle.h

   Descr.: - todo -

   Author: Stefan Leihkauf
   Date:   9/5/2012
*/
//-------------------------------------------------------------------------
#ifndef _ROOT_KEY_HANDLE_H
#define _ROOT_KEY_HANDLE_H
#include <boost\noncopyable.hpp>

namespace registry_detail {
	/* Windows defines a special type of handles for predefined registry rootkeys.
	Such handles are so called pseudohandles and predefined constants of type HKEY.
	These handles can not be closed via CloseHandle API or duplicated via DuplicateHandle API.
	These predefined constants are not manageable with the handle wrapper so I
	decided to wrap them in an special class.
	*/
	class root_key_handle : boost::noncopyable {
	private:
		const HKEY _value;
		const StdString _name;

	public:
		/// constructor
		inline root_key_handle(const HKEY& value, const StdString&  name) :
		_value(value), _name(name) { /* empty */ }

		/// convert to string
		inline const StdString& toString() const { return _name; }

		/// implicit conversion to HKEY
		inline operator HKEY() const { return _value; }

		/// equality
		inline bool operator == (const root_key_handle& other) const {
			return (this->_value == other._value);
		}
	};
} // namespace detail

#endif //!defined _ROOT_KEY_HANDLE_H